package net.nagaseyasuhito.nicola.component;

import java.util.List;

import net.nagaseyasuhito.nicola.entity.Entry;
import net.nagaseyasuhito.nicola.entity.User;

import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.StringResourceModel;

public class ReplyEntriesTab extends AbstractTab {
	private static final long serialVersionUID = 1L;

	private User user;
	private int maxResults;

	public ReplyEntriesTab(User user, int maxResults) {
		super(new StringResourceModel("replyEntries", null, null));
		this.user = user;
		this.maxResults = maxResults;
	}

	@Override
	public Panel getPanel(String panelId) {
		return new EntriesPanel(panelId, this.maxResults) {
			private static final long serialVersionUID = 1L;

			@Override
			public List<Entry> loadEntries(int firstResult, int maxResults) {
				return this.entryService.findAllRepliesByUser(user, firstResult, maxResults);
			}

			@Override
			public long countEntries() {
				return this.entryService.countAllRepliesByUser(user);
			}
		};
	}
}